#! /bin/sh
####################################################################################
#                                                                                  #
#  Copyright (c) 1996, Sun Microsystems Computer Corporation, Mountain View, CA    #
#                                                                                  #
#                      All Rights Reserved                                         #
#                                                                                  #
# Sun Microsystems Computer Corporation disclaims all warranties with              #
# regard to this software, including all implied warranties of merchantability     #
# and fitness.  In no event will Sun Microsystems Inc., Sun Microsystems           #
# Computer Corporation or any Sun Microsystems Inc. company, its employees         #
# or agents be liable for direct, incidental or consequential damages              #
# resulting from loss of data or business opportunities, resulting from the        #
# Ultracomputing Demo CD, or any part of same, either alone or in conjunction      #
# with other programs.                                                             #
#                                                                                  #
# The software contained on these discs is distributed as is, at no additional     #
# charge. As such, it is excluded from any pre-existing customer service 	   #
# or support agreements with Sun Microsystems. An email form is provided in 	   #
# the main demo menu to direct comments, feedback and technical questions          #
# relating strictly to Ultrapack, the demos and usage thereof.			   #
#                                                                                  #
# install.sh:									   #
#                                                                                  #
# Executable shell script for installing the UltraPack				   #
# 		SMCC Desktop Systems Engineering				   #
#		March 1996				   			   #
#										   #
####################################################################################
#set -x

FALSE=0
TRUE=1

if [ "$ULTRA_PACK_HOME" != "" ]; then
	cd $ULTRA_PACK_HOME;
else
	echo "Please setenv ULTRA_PACK_HOME";
fi

/bin/clear
echo " "
echo "Ultra Pack Partner Demo install utility..."
echo " "
echo " "
echo " "
echo "This utility will copy the contents of this CDROM to a directory"
echo "which you have permission to write to. Once copied, you can run"
echo "the demos from that directory. Note, for both the TCL/TK and the"
echo "Faximum demos, you will still need to further install them. For"
echo "more information, see the 'About' section of either demo..."
echo
echo " "
echo "	1. Install UltraPack Partner demos (~186 Mbyte)"
echo " "
echo "	2. Quit"
echo " "
read reply

if [ "$reply" != "1" ]; then
	echo " "
	echo "Quitting..."
	echo " "
	sleep 1
	exit;
fi

echo " "
echo "Enter path to install..."
read instpath

if [ "$instpath" = "" ]; then
	echo "Must specify a pathname";
	echo "Exiting";
	/usr/bin/sleep 2;
	exit;
fi

if [ ! -d $instpath ]; then
	echo " ";
	echo "Path does not exist, create (y/n)";
	read reply;

	if [ "$reply" = "y" ] || ["$reply" = "Y" ] ; then
	    mkdir $instpath;
	elif
	[ "$reply" = "n" ] || ["$reply" = "N" ] ; then
	    echo "Exiting";
	    sleep 2;
	    exit;
	fi
fi

if [ ! -w $instpath ]; then
    echo " ";
    echo "Permission denied"
    echo "Exiting ";
    sleep 2;
    exit;
fi

/usr/bin/tar cvf - . | (cd $instpath; tar xf - )

tmpfil=/tmp/.iU_d_$$
sed -e "s;/cdrom/cdrom0;$instpath;g"  $instpath/Caldera/Cameleo/bin/.CAS.config | sed -e "s;//;/;g" > $tmpfil
mv $tmpfil $instpath/Caldera/Cameleo/bin/.CAS.config
cp $instpath/Caldera/Cameleo/bin/.CAS.config $instpath/Caldera/Cameleo/lib/.CAS.config

sed -e "s;/cdrom/cdrom0;$instpath;g" -e "s;^#ULTRA_PACK_HOME=;ULTRA_PACK_HOME=;" $instpath/run_demo > $tmpfil
mv $tmpfil $instpath/run_demo
chmod 755 $instpath/run_demo

/bin/sleep 2
/bin/clear
echo " "
echo "The UltraPack Partner demos have been successfully installed to:" 
echo " "
echo $instpath
echo " "
echo "To run the demo's, double click on the run_demo icon"
echo "with File Manager in " $instpath
echo " "
echo "...or, to run from Unix command line, you need to include the path"
echo $instpath "in your shell search path"
echo " "
echo "Press the <RETURN> key to exit install"
read replay
